home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
redakcyjne
/
programy
/
FEBE (Firefox Environment Backup Extension) 5.0
/
febe-5.0-fx.xpi
/
chrome
/
febe.jar
/
content
/
febeCommon.js
< prev
next >
Wrap
Text File
|
2007-06-19
|
44KB
|
1,013 lines
// author: Chuck Baker
// contact: febe@customsoftwareconsult.com
// Version 5.0
//
// Common (global) variables
var FEBE_GUID = "{4BBDD651-70CF-4821-84F8-2B918CF89CA3}" // GUID of this extension
var FEBEnsISupportsString = Components.interfaces.nsISupportsString;
var FEBEWINZIPFILENAME = "FEBEzip.exe";
var FEBEWINUNZIPFILENAME = "FEBEunzip.exe";
var FEBENIXZIPFILENAME = "FEBEnixzip";
var FEBENIXUNZIPFILENAME = "FEBEnixunzip";
var FEBEMACZIPFILENAME = "FEBEmaczip";
var FEBEMACUNZIPFILENAME = "FEBEmacunzip";
var FEBEDATAFILE = "febeUserDefinedBuData.dat";
// Get pointer to preferences
try{
var febePrefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch("");
}catch(e){
var msg = febeMsg[169];
febeFatal(e,msg);}
function febeGetUnicharPref(prefName) {
return febePrefs.getComplexValue(prefName, FEBEnsISupportsString).data;
}
function febeSetUnicharPref(prefName, prefValue) {
var supportsString = Components.classes["@mozilla.org/supports-string;1"].createInstance(FEBEnsISupportsString);
supportsString.data = prefValue;
febePrefs.setComplexValue(prefName, FEBEnsISupportsString, supportsString);
}
window.addEventListener("load",febeSetMsgs,true);
// Set global variables
var febeBUtype = new String(); // "selective" or "profile"
var febeExBuDir = new String(); // Directory where the results are stored
var febeBUdate = new Date(); // Date of backup to restore
var febePathName = new String(); // Holds full path name of various files
var febeDebugMode = new Boolean(false);// In debug mode?
var febeExtensionsList = {}; // Array holding extension names
var febeThemesList = {}; // Array holding theme names
var febeErrorList = []; // Array holding failed items (errors)
var febeWarningList = []; // Array holding failed items (warnings)
var febeETinstall = []; // Array of ext/theme objects to install
var febeMsg = []; // Array holding localized strings
var febeTmpDir = new String(); // nsIFile pointer to temp directory
var febeDestDir = new String(); // nsIFile pointer used in febeDirCopy()
var febeSubRootDir = new String(); // Used in febeDirCopy()
var febeBuSeq = new String(); // FEBE Batch Sequence number
var FEBEdir = new String(); // Pointer to FEBE extension directory
var febeZipFile = new String(); // Pointer to "FEBE.zip"
var febeUnZipFile = new String(); // Pointer to "FEBEunzip.zip"
var FEBEbg = new String(); // Pointer to "FEBEbg.exe" (background program)
var febeWin = new String(); // Window object for FEBE windows
var febeProfDir = new String(); // Full path to profile directory
var febeProfName = new String(); // Profile name
var febeVersion = new String(); // Version of this extension (FEBE)
var febePrName = new String(); // Leafname of file picker file
var febeBuDesDir = new String(); // Pointer to backup destination directory
var febeExtExt = new String(); // ".xpi" (extension) or ".jar" (theme)
var febeBuInProgress = new Boolean(false); // Is the backup running?
var febeInitialized = new Boolean(false); // Initalize function run yet?
var febeUseTimestampedDir = new Boolean(false);// Create timestamped subdirectories?
var febeMaxDirs = new Number; // Maximum number of timestamped directories
var febeClearDestDir = new Boolean(false); // Clear destination directory?
var febeProfList = []; // Array of febeProfileObj objects
var febePlatform = new Number; // 1=Windows, 2=*nix, 3=Mac
var febePathDelimiter = new String(); // Backslash for Windows, slash for Linux
var febeNLchar = new String(); // Newline character - Windows: "\r\n", Linux: "\n"
var febeDisabledCount = new Number; // Count of disabled extensions
var includeFEBE = new String(); // Include a copy of FEBE with backup?
var febeDisablePermChk = new Boolean(false); // Disable zip/unzip permission check?
var febeUDBuDone = []; // Array of completed User-defined backups
var febeClipboard = []; // Holds alert messages for the clipboard
var febeIgnoreError = new Boolean(false); // If true, don't display error message
var febeReminded = new Boolean(false); // If true, dont show backup reminder
// Preferences
var buExtensions = new Boolean(false); // Backup extensions?
var buThemes = new Boolean(false); // Backup themes?
var buBookmarks = new Boolean(false); // Backup bookmarks.html?
var buPreferences = new Boolean(false); // Backup prefs.js?
var buCookies = new Boolean(false); // Backup cookies.txt?
var buUserChrome = new Boolean(false); // Backup userChrome.css?
var buUserContent = new Boolean(false); // Backup userContent.css?
var buUserPwd = new Boolean(false); // Backup key3.db and signons.txt?
var buPhishingData = new Boolean(false); // Backup kf.txt and urlclassifier.sqlite?
var buSearchPlugins = new Boolean(false); // Backup searchplungins directory?
var buBrowserHistory = new Boolean(false); // Backup history.dat?
var buFormFillHistory = new Boolean(false);// Backup formhistory.dat?
var buPermissions = new Boolean(false); // Backup hostperm.1?
var buUDBu = new Boolean(false); // Backup User-defined backups?
var buProfile = new Boolean(false); // Backup entire profile?
var ignoreDisabled = new Boolean(false); // Ignore disabled extension?
var febeHideIcons = new Boolean(false); // Hide statusbar icons?
var febeVerifyBackups = new Boolean(false);// Verify backups?
var febeHideHelp = new Boolean(false); // Hide help icons?
var febeDispProgress = new Boolean(false); // Display progress window?
var febeDispResults = new Boolean(false); // Display results page?
var febePlaySounds = new Boolean(false); // Play sounds?
var febeSetTimeOutID = new Number; // ID of setTimeout function
// Backup flags
var exBackedUp = new Boolean(false); // Did extensions backup ok?
var thBackedUp = new Boolean(false); // Did themes backup ok?
var bmBackedUp = new Boolean(false); // Did bookmarks backup ok?
var prBackedUp = new Boolean(false); // Did the preferences backup ok?
var ckBackedUp = new Boolean(false); // Did cookies backup ok?
var chBackedUp = new Boolean(false); // Did user chrome backup ok?
var ucBackedUp = new Boolean(false); // Did user content backup ok?
var pwBackedUp = new Boolean(false); // Did passwords backup ok?
var pdBackedUp = new Boolean(false); // Did phishing data backup ok?
var spBackedUp = new Boolean(false); // Did search plugins backup ok?
var hsBackedUp = new Boolean(false); // Did history backup ok?
var ffBackedUp = new Boolean(false); // Did form fill history backup ok?
var pmBackedUp = new Boolean(false); // Did permissions file backup ok?
var udBackedUp = new Number; // Number of User-defined bu's backed up
var upBackedUp = new Boolean(false); // Did the user profile backup ok?
// Backup file names
var bmBuName = new String(); // Bookmarks backup filename
var prBuName = new String(); // Preferences backup filename
var ckBuName = new String(); // Cookies backup filename
var chBuName = new String(); // UserChrome backup filename
var ucBuName = new String(); // UserContent backup filename
var pwBuName = new String(); // Password backup filename
var pdBuName = new String(); // Phishing data backup filename
var spBuName = new String(); // Search plugins backup filename
var hsBuName = new String(); // Browser history backup filename
var ffBuName = new String(); // Form fill history backup filename
var pmBuName = new String(); // Permissions backup filename
var udBuName = new String(); // User-defined backup filename
var upBuName = new String(); // User profile backup filename
function febeSetMsgs(){
// Error messages, prompts, etc.
var fs = document.getElementById('febe-strings');
febeMsg.push(fs.getString("msg00")); // "Destination directory"
febeMsg.push(fs.getString("msg01")); // "does not exsist!"
febeMsg.push(fs.getString("msg02")); // "Specify valid directory in FEBE options and try again"
febeMsg.push(fs.getString("msg03")); // "Extension destination directory not set."
febeMsg.push(fs.getString("msg04")); // "Run FEBE options and try again."
febeMsg.push(fs.getString("msg05")); // "Select destination directory"
febeMsg.push(fs.getString("msg06")); // "Destination profile cannot be the current (active) profile!"
febeMsg.push(fs.getString("msg07")); // "Version unknown"
febeMsg.push(fs.getString("msg08")); // "Debug mode on ..."
febeMsg.push(fs.getString("msg09")); // "Front end batch file can be viewed at: "
febeMsg.push(fs.getString("msg10")); // "Backup batch file can be viewed at: "
febeMsg.push(fs.getString("msg11")); // "Log file can be viewed at: "
febeMsg.push(fs.getString("msg12")); // "Items processed:"
febeMsg.push(fs.getString("msg13")); // "total"
febeMsg.push(fs.getString("msg14")); // "Extensions backed up:"
febeMsg.push(fs.getString("msg15")); // "Created in:"
febeMsg.push(fs.getString("msg16")); // "Themes backed up: "
febeMsg.push(fs.getString("msg17")); // "Items skipped:"
febeMsg.push(fs.getString("msg18")); // "Could not verify extension/theme with GUID:"
febeMsg.push(fs.getString("msg19")); // "Could not find any extensions to backup!"
febeMsg.push(fs.getString("msg20")); // "FEBE Results"
febeMsg.push(fs.getString("msg21")); // "Backup in progress ..."
febeMsg.push(fs.getString("msg22")); // "This window will close when the backup completes."
febeMsg.push(fs.getString("msg23")); // "Closing this window manually will abort the backup."
febeMsg.push(fs.getString("msg24")); // "Select one or more themes to install"
febeMsg.push(fs.getString("msg25")); // "Select one or more extension to install"
febeMsg.push(fs.getString("msg26")); // "FEBE processing:"
febeMsg.push(fs.getString("msg27")); // "Bookmarks backed to:"
febeMsg.push(fs.getString("msg28")); // "Preferences backed up to:"
febeMsg.push(fs.getString("msg29")); // "Cookies backed up to:"
febeMsg.push(fs.getString("msg30")); // "Could not backup bookmarks!"
febeMsg.push(fs.getString("msg31")); // "Could not backup preferences!"
febeMsg.push(fs.getString("msg32")); // "Could not backup cookies!"
febeMsg.push(fs.getString("msg33")); // "Select bookmarks file to restore"
febeMsg.push(fs.getString("msg34")); // "Select prefrences file to restore"
febeMsg.push(fs.getString("msg35")); // "Select cookies file to restore"
febeMsg.push(fs.getString("msg36")); // "Warning!"
febeMsg.push(fs.getString("msg37")); // "You are about to restore bookmarks dated"
febeMsg.push(fs.getString("msg38")); // "You are about to restore preferences dated"
febeMsg.push(fs.getString("msg39")); // "You are about to restore cookies dated"
febeMsg.push(fs.getString("msg40")); // "Once completed, this cannot be undone."
febeMsg.push(fs.getString("msg41")); // "Ok to proceed?"
febeMsg.push(fs.getString("msg42")); // "Bookmarks have been restored."
febeMsg.push(fs.getString("msg43")); // "Preferences have been restored."
febeMsg.push(fs.getString("msg44")); // "Cookies have been restored."
febeMsg.push(fs.getString("msg45")); // "Any changes made since that point will be lost."
febeMsg.push(fs.getString("msg46")); // "Restore aborted"
febeMsg.push(fs.getString("msg47")); // "Cannot find wscript.exe!"
febeMsg.push(fs.getString("msg48")); // "Specify path to wscript.exe in FEBE options."
febeMsg.push(fs.getString("msg49")); // "Version:"
febeMsg.push(fs.getString("msg50")); // "Bookmarks will be restored when Firefox restarts."
febeMsg.push(fs.getString("msg51")); // "Restart Firefox now?"
febeMsg.push(fs.getString("msg52")); // "User Chrome backed up to:"
febeMsg.push(fs.getString("msg53")); // "User Content backed up to:"
febeMsg.push(fs.getString("msg54")); // "Usernames and Passwords backed up to:"
febeMsg.push(fs.getString("msg55")); // "Phishing data backed up to:"
febeMsg.push(fs.getString("msg56")); // "Search Plugins backed up to:"
febeMsg.push(fs.getString("msg57")); // "Browser History backed up to:"
febeMsg.push(fs.getString("msg58")); // "Form Fill History backed up to:"
febeMsg.push(fs.getString("msg59")); // "Profile backed up to:"
febeMsg.push(fs.getString("msg60")); // "Could not backup userChrome!"
febeMsg.push(fs.getString("msg61")); // "Could not backup userContent!"
febeMsg.push(fs.getString("msg62")); // "Could not backup usernames and passwords!"
febeMsg.push(fs.getString("msg63")); // "Could not backup phishing data!"
febeMsg.push(fs.getString("msg64")); // "Could not backup search plugins!"
febeMsg.push(fs.getString("msg65")); // "Could not backup browser history!"
febeMsg.push(fs.getString("msg66")); // "Could not backup form fill history!"
febeMsg.push(fs.getString("msg67")); // "Could not backup profile!"
febeMsg.push(fs.getString("msg68")); // "You are about to restore userChrome.css dated"
febeMsg.push(fs.getString("msg69")); // "You are about to restore userContent.css dated"
febeMsg.push(fs.getString("msg70")); // "You are about to restore usernames and passwords dated"
febeMsg.push(fs.getString("msg71")); // "You are about to restore phishing data dated"
febeMsg.push(fs.getString("msg72")); // "You are about to restore search plugins dated"
febeMsg.push(fs.getString("msg73")); // "You are about to restore browser history dated"
febeMsg.push(fs.getString("msg74")); // "You are about to restore form fill history dated"
febeMsg.push(fs.getString("msg75")); // "You are about to restore a profile dated"
febeMsg.push(fs.getString("msg76")); // "Individual batch files located in "
febeMsg.push(fs.getString("msg77")); // "Prepairing results page ..."
febeMsg.push(fs.getString("msg78")); // "Select userChrome file to restore"
febeMsg.push(fs.getString("msg79")); // "User chrome has been restored."
febeMsg.push(fs.getString("msg80")); // "Select username-passwords file to restore"
febeMsg.push(fs.getString("msg81")); // "Usernames and passwords have been restored."
febeMsg.push(fs.getString("msg82")); // "Select phishing data file to restore"
febeMsg.push(fs.getString("msg83")); // "Phishing data have been restored."
febeMsg.push(fs.getString("msg84")); // "Select search plugins file to restore"
febeMsg.push(fs.getString("msg85")); // "Search plugins have been restored."
febeMsg.push(fs.getString("msg86")); // "Select browser history file to restore"
febeMsg.push(fs.getString("msg87")); // "Browser history has been restored."
febeMsg.push(fs.getString("msg88")); // "Select form fill history file to restore"
febeMsg.push(fs.getString("msg89")); // "Form fill history has been restored."
febeMsg.push(fs.getString("msg90")); // "Select profile to restore"
febeMsg.push(fs.getString("msg91")); // "Profile has been restored."
febeMsg.push(fs.getString("msg92")); // "Select userContent file to restore"
febeMsg.push(fs.getString("msg93")); // "User content has been restored."
febeMsg.push(fs.getString("msg94")); // "Usernames and passwords will be restored when Firefox restarts."
febeMsg.push(fs.getString("msg95")); // "Username and password restore failed!"
febeMsg.push(fs.getString("msg96")); // "Phishing data will be restored when firefox restarts"
febeMsg.push(fs.getString("msg97")); // "Search plugins restore failed!"
febeMsg.push(fs.getString("msg98")); // "Confirm delete"
febeMsg.push(fs.getString("msg99")); // "The backup destination directory contains x1 files and x2 subdirectories."
febeMsg.push(fs.getString("msg100")); // "All files will be deleted! (Subdirectories, if any, will not be removed.)"
febeMsg.push(fs.getString("msg101")); // "Enter a positive whole number or zero for unlimited."
febeMsg.push(fs.getString("msg102")); // "Profile restore failed!"
febeMsg.push(fs.getString("msg103")); // "Phishing data restore failed!"
febeMsg.push(fs.getString("msg104")); // "Permissions successfuly changed"
febeMsg.push(fs.getString("msg105")); // "Could not determine if permissions were changed. Please set/check manually."
febeMsg.push(fs.getString("msg106")); // "Browser history will be restored when Firefox restarts."
febeMsg.push(fs.getString("msg107")); // "Does not include %num% disabled extensions."
febeMsg.push(fs.getString("msg108")); // "FEBE Results"
febeMsg.push(fs.getString("msg109")); // "FEBE Results Report"
febeMsg.push(fs.getString("msg110")); // "For the latest information, see the"
febeMsg.push(fs.getString("msg111")); // "FEBE homepage."
febeMsg.push(fs.getString("msg112")); // "error(s) encountered."
febeMsg.push(fs.getString("msg113")); // "-- Not selected --"
febeMsg.push(fs.getString("msg114")); // "Next scheduled backup:"
febeMsg.push(fs.getString("msg115")); // "Could not backup permissions!"
febeMsg.push(fs.getString("msg116")); // "Permissions backed up to:"
febeMsg.push(fs.getString("msg117")); // "Select permissions file to restore"
febeMsg.push(fs.getString("msg118")); // "You are about to restore permissions dated"
febeMsg.push(fs.getString("msg119")); // "Permissions have been restored."
febeMsg.push(fs.getString("msg120")); // "%disabled% indicates a user disabled extension."
febeMsg.push(fs.getString("msg121")); // "Does not exist"
febeMsg.push(fs.getString("msg122")); // "Exists, but empty"
febeMsg.push(fs.getString("msg123")); // "Exists with entries"
febeMsg.push(fs.getString("msg124")); // "Tmp directory deleted"
febeMsg.push(fs.getString("msg125")); // "Could not remove tmp directory!"
febeMsg.push(fs.getString("msg126")); // "Clicking 'OK' will reset all FEBE preferences to default values."
febeMsg.push(fs.getString("msg127")); // "This cannot be undone."
febeMsg.push(fs.getString("msg128")); // "Are you sure you want to proceed?"
febeMsg.push(fs.getString("msg129")); // "FEBE preferences have been reset."
febeMsg.push(fs.getString("msg130")); // "FEBE tmp directory created."
febeMsg.push(fs.getString("msg131")); // "Nothing is selected for backup! Run FEBE options and select some backup items."
febeMsg.push(fs.getString("msg132")); // "warning(s) encountered."
febeMsg.push(fs.getString("msg133")); // "Select a file or directory to backup"
febeMsg.push(fs.getString("msg134")); // "Select a function:"
febeMsg.push(fs.getString("msg135")); // "Select..."
febeMsg.push(fs.getString("msg136")); // "Add a new item"
febeMsg.push(fs.getString("msg137")); // "Change/View an item"
febeMsg.push(fs.getString("msg138")); // "Delete an item"
febeMsg.push(fs.getString("msg139")); // "You have transactions pending."
febeMsg.push(fs.getString("msg140")); // "Database will NOT be updated!"
febeMsg.push(fs.getString("msg141")); // "Click 'OK' to exit anyway, 'Cancel' to return to form."
febeMsg.push(fs.getString("msg142")); // "Label cannot be blank"
febeMsg.push(fs.getString("msg143")); // "Description cannot be blank"
febeMsg.push(fs.getString("msg144")); // "Source cannot be blank"
febeMsg.push(fs.getString("msg145")); // "Entry labeled '%key%' already exists ... Choose a different label"
febeMsg.push(fs.getString("msg146")); // "Submited ... will be written on exit."
febeMsg.push(fs.getString("msg147")); // "User-defined backup"
febeMsg.push(fs.getString("msg148")); // "User-defined %description% backed up to: %name%"
febeMsg.push(fs.getString("msg149")); // "Database updated"
febeMsg.push(fs.getString("msg150")); // "Scheduled backup aborted!"
febeMsg.push(fs.getString("msg151")); // "Backup scheduling has been turned off."
febeMsg.push(fs.getString("msg152")); // "Use FEBE options to reset."
febeMsg.push(fs.getString("msg153")); // "(Not set)"
febeMsg.push(fs.getString("msg154")); // "Select FEBE tmp directory"
febeMsg.push(fs.getString("msg155")); // "FEBE has determined that this is a new install or update"
febeMsg.push(fs.getString("msg156")); // "Please set FEBE options before attempting a backup."
febeMsg.push(fs.getString("msg157")); // "If this is an update, you should clear the previous preferences."
febeMsg.push(fs.getString("msg158")); // "(FEBE Options > Debug > Misc > 'Clear FEBE preferences')"
febeMsg.push(fs.getString("msg159")); // "Select a folder to backup"
febeMsg.push(fs.getString("msg160")); // "Select 'File' or 'Folder'"
febeMsg.push(fs.getString("msg161")); // "Select User-defined backup to restore"
febeMsg.push(fs.getString("msg162")); // "Error occured attempting to rename profile. Details:"
febeMsg.push(fs.getString("msg163")); // "You are about to restore %fname% dated"
febeMsg.push(fs.getString("msg164")); // "%fname% has been restored"
febeMsg.push(fs.getString("msg165")); // "Please select 'File' or 'Folder' type first."
febeMsg.push(fs.getString("msg166")); // "Can't find user-defined backup file %path%"
febeMsg.push(fs.getString("msg167")); // "*** Error backing up %description%"
febeMsg.push(fs.getString("msg168")); // "Could not copy %sourcefile% to %destdir% as %dName%"
febeMsg.push(fs.getString("msg169")); // "A possibly fatal error has occured. "
febeMsg.push(fs.getString("msg170")); // "Restore"
febeMsg.push(fs.getString("msg171")); // "Backup reminder!"
febeMsg.push(fs.getString("msg172")); // "Last backup was performed over %days% day(s) ago on:"
febeMsg.push(fs.getString("msg173")); // "No backup performed)"
febeMsg.push(fs.getString("msg174")); // "All user-defined items will be deleted and set to default."
febeMsg.push(fs.getString("msg175")); // "Click 'OK' to reset, 'Cancel' to return to form."
febeMsg.push(fs.getString("msg176")); // "User-defined data reset to default."
febeMsg.push(fs.getString("msg177")); // "If the permissions are set correctly and you continue to get this message,"
febeMsg.push(fs.getString("msg178")); // "disable permissions check in 'FEBE Options > Debug > Misc'."
febeMsg.push(fs.getString("msg179")); // "Are you sure you want to abort?"
febeMsg.push(fs.getString("msg180")); // "by:"
febeMsg.push(fs.getString("msg181")); // "FEBE user-defined backup data"
febeMsg.push(fs.getString("msg182")); // "FEBE data"
}//febeSetMsgs()
function febeGetPrefs(){
// Get/set the preferences
// Get timestamp flag
var prefName = "extensions.febe.useTimestampedDir";
if(febePrefs.prefHasUserValue(prefName)){
febeUseTimestampedDir = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febeUseTimestampedDir = false;
}//if
// Get max number of timestamped directories
var prefName = "extensions.febe.maxBuDirs";
if(febePrefs.prefHasUserValue(prefName)){
febeMaxDirs = febePrefs.getIntPref(prefName);
} else {
febePrefs.setIntPref(prefName,0);
febeMaxDirs = 0; // Zero means no limit
}//if
// Get clear directory flag
var prefName = "extensions.febe.clearDestDir";
if(febePrefs.prefHasUserValue(prefName)){
febeClearDestDir = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febeClearDestDir = false;
}//if
// Get backup option flags
var prefName = "extensions.febe.buType";
if(febePrefs.prefHasUserValue(prefName)){
febeBUtype = febePrefs.getCharPref(prefName);
} else {
febePrefs.setCharPref(prefName,"selective");
febeBUtype = "selective";
}//if
if(febeBUtype == "selective"){
buProfile = false;
}else{
buProfile = true;
}//if
var prefName = "extensions.febe.buExtensions";
if(febePrefs.prefHasUserValue(prefName)){
buExtensions = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,true);
buExtensions = true;
}//if
var prefName = "extensions.febe.buThemes";
if(febePrefs.prefHasUserValue(prefName)){
buThemes = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,true);
buThemes = true;
}//if
var prefName = "extensions.febe.buBookmarks";
if(febePrefs.prefHasUserValue(prefName)){
buBookmarks = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buBookmarks = false;
}//if
var prefName = "extensions.febe.buPreferences";
if(febePrefs.prefHasUserValue(prefName)){
buPreferences = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buPreferences = false;
}//if
var prefName = "extensions.febe.buCookies";
if(febePrefs.prefHasUserValue(prefName)){
buCookies = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buCookies = false;
}//if
var prefName = "extensions.febe.buUserChrome";
if(febePrefs.prefHasUserValue(prefName)){
buUserChrome = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buUserChrome = false;
}//if
var prefName = "extensions.febe.buUserContent";
if(febePrefs.prefHasUserValue(prefName)){
buUserContent = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buUserContent = false;
}//if
var prefName = "extensions.febe.buUserPwd";
if(febePrefs.prefHasUserValue(prefName)){
buUserPwd = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buUserPwd = false;
}//if
var prefName = "extensions.febe.buPhishingData";
if(febePrefs.prefHasUserValue(prefName)){
buPhishingData = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buPhishingData = false;
}//if
var prefName = "extensions.febe.buSearchPlugins";
if(febePrefs.prefHasUserValue(prefName)){
buSearchPlugins = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buSearchPlugins = false;
}//if
var prefName = "extensions.febe.buBrowserHistory";
if(febePrefs.prefHasUserValue(prefName)){
buBrowserHistory = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buBrowserHistory = false;
}//if
var prefName = "extensions.febe.buFormFillHistory";
if(febePrefs.prefHasUserValue(prefName)){
buFormFillHistory = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buFormFillHistory = false;
}//if
var prefName = "extensions.febe.buPermissions";
if(febePrefs.prefHasUserValue(prefName)){
buPermissions = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buPermissions = false;
}//if
var prefName = "extensions.febe.buUDBu";
if(febePrefs.prefHasUserValue(prefName)){
buUDBu = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
buUDBu = false;
}//if
var prefName = "extensions.febe.ignoreDisabled";
if(febePrefs.prefHasUserValue(prefName)){
ignoreDisabled = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
ignoreDisabled = false;
}//if
// Get debug mode
var prefName = "extensions.febe.debugMode";
if(febePrefs.prefHasUserValue(prefName)){
febeDebugMode = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febeDebugMode = false;
}//if
// Verify backups?
var prefName = "extensions.febe.verifyBackups";
if(febePrefs.prefHasUserValue(prefName)){
febeVerifyBackups = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febeVerifyBackups = false;
}//if
// Play sounds?
var prefName = "extensions.febe.playSounds";
if(febePrefs.prefHasUserValue(prefName)){
febePlaySounds = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febePlaySounds = false;
}//if
// Hide help icons?
var prefName = "extensions.febe.hidehelp";
if(febePrefs.prefHasUserValue(prefName)){
febeHideHelp = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febeHideHelp = false;
}//if
febeHideHelpIcons();
// Display progress window?
var prefName = "extensions.febe.displayprogresswin";
if(febePrefs.prefHasUserValue(prefName)){
febeDispProgress = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,true);
febeDispProgress = true;
}//if
// Display results page?
var prefName = "extensions.febe.displayresultspage";
if(febePrefs.prefHasUserValue(prefName)){
febeDispResults = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,true);
febeDispResults = true;
}//if
// Include a copy of FEBE with backup?
var prefName = "extensions.febe.includefebe";
if(febePrefs.prefHasUserValue(prefName)){
includeFEBE = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
includeFEBE = false;
}//if
// Disable permission check?
var prefName = "extensions.febe.disablepermissioncheck";
if(febePrefs.prefHasUserValue(prefName)){
febeDisablePermChk = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febeDisablePermChk = false;
}//if
// Set reminder days if empty
var prefName = "extensions.febe.reminderdays";
if(!febePrefs.prefHasUserValue(prefName)){febePrefs.setIntPref(prefName,0);}
// Set HTML text orientation
var prefName = "extensions.febe.orientation";
if(!febePrefs.prefHasUserValue(prefName)){febePrefs.setCharPref(prefName,"ltr");}
// Get febe tmp directory information
var td = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("TmpD", Components.interfaces.nsIFile);
td.append("febe.tmp");
var prefName = "extensions.febe.tmpDefaultDirectory";
var dflt = td.path;
febeInitPref(prefName, dflt);
var prefName = "extensions.febe.tmpSpecifyDirectory";
var dflt = febeMsg[153];
febeInitPref(prefName, dflt);
var prefName = "extensions.febe.tmpDirType";
var dflt = "Default";
febeInitPref(prefName, dflt);
var tmpDirType = febePrefs.getCharPref(prefName);
switch(tmpDirType){
case "Default": var whichPref = "extensions.febe.tmpDefaultDirectory";break;
case "Specified": var whichPref = "extensions.febe.tmpSpecifyDirectory";break;
default: var whichPref = "extensions.febe.tmpDefaultDirectory";break;
}//switch
var td = febeGetUnicharPref(whichPref);
var prefName = "extensions.febe.tmpDirectory";
febeSetUnicharPref(prefName,td);
return true;
}//febeGetPrefs()
function febeInitPref(prefName, dflt){
// Set a preference to default if needed
if(!febePrefs.prefHasUserValue(prefName)){
febeSetUnicharPref(prefName,dflt);
}else if(febeGetUnicharPref(prefName) == ""){
febeSetUnicharPref(prefName,dflt);
}//if
//alert(prefName+"\n["+febeGetUnicharPref(prefName)+"]")
return true;
}//febeInitPref()
function febeHelp(helpIndex){
var helpFile = "chrome://febe/content/febeHelp_"+helpIndex+".xul"
var helpWin = window.open(helpFile, "FEBE Help", "chrome,alwaysRaised,centerscreen,resizable");
return true;
}//febeHelp()
// Object declarations
function febeExtObj(Name, Path, Icon, Home, guid, verified){
this.Name = new String(Name);
this.Path = new String(Path);
this.Icon = new String(Icon);
this.Home = new String(Home);
this.guid = new String(guid);
this.verified = new Boolean(verified);
return true;
}//febeExtObj
function febeProfileObj(Name, Path){
this.Name = Name;
this.Path = Path;
return true;
}//febeProfileObj object
function febeUDBuDoneObj(Description, Name){
this.Description = Description;
this.Name = Name;
return true;
}//febeUDBuDoneObj()
function febeSetTimeoutObj(PID,Process){
this.PID = PID;
this.Process = Process;
return true;
}//febeSetTimeoutObj
function febeGetPlatform(){
var platform = navigator.platform.toLowerCase();
if(platform.indexOf("win") != -1){febePlatform = 1;}
if(platform.indexOf("linux") != -1){febePlatform = 2;}
if(platform.indexOf("unix") != -1){febePlatform = 2;}
if(platform.indexOf("darwin") != -1){febePlatform = 3;}
if(platform.indexOf("macintel") != -1){febePlatform = 3;}
if(platform.indexOf("macppc") != -1){febePlatform = 3;}
//febePlatform = 2;
var OS = "???";
switch (febePlatform) {
case 1: febePathDelimiter = "\\"; OS = "Windows"; break;
case 2: febePathDelimiter = "/" ; OS = "Unix/Linux"; break;
case 3: febePathDelimiter = "/" ; OS = "Mac (freeBSD)"; break;
default: febePlatform = -1; return false;
}//switch
if(document.getElementById("febePlatformLableID")){
document.getElementById("febePlatformID").value = navigator.platform;
document.getElementById("febeOsID").value= OS;
}//if
if(document.getElementById("febeInstallPath")){
FEBEdir = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager)
.getInstallLocation(FEBE_GUID)
.getItemLocation(FEBE_GUID);
document.getElementById("febeInstallPath").value = FEBEdir.path;
}//if
return febePlatform;
}//febeGetPlatform()
function getFebeVersion() {
var em = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
var ext = null;
if (em.getItemForID){
ext = em.getItemForID(FEBE_GUID);
}else{
ext = em.getItemList(FEBE_GUID, null, {})[0];
}//if
return ext.version;
}//getFebeVersion()
function setFebeVersion(){
febeSetMsgs();
var version = getFebeVersion();
document.getElementById("febeVersionID").value = febeMsg[49]+" "+version;
version = Components.classes['@mozilla.org/xre/app-info;1']
.getService(Components.interfaces.nsIXULAppInfo).version;
if(document.getElementById("febeFxVersionID")){
document.getElementById("febeFxVersionID").value = version;
}//if
return true;
}//setFebeVersion()
function febeValidateMaxDirs(){
var maxDirs = document.getElementById("maxBuDirsID").value;
if(isNaN(maxDirs)){
var w = this.window;
febeAlert(febeMsg[101]);
w.focus();
document.getElementById("maxBuDirsID").focus();
document.getElementById("maxBuDirsID").select();
return false;
}//if
document.getElementById("maxBuDirsID").value = parseInt(maxDirs);
return true;
}//febeValidateMaxDirs()
function febeOpenLink(URL){
if(!URL){return;}
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
var febeGetBrowser = win.getBrowser();
var currBlank = (febeGetBrowser &&
(febeGetBrowser.mCurrentTab.linkedBrowser &&
(febeGetBrowser.mCurrentTab.linkedBrowser.contentDocument.location == "about:blank")) ||
(!febeGetBrowser.mCurrentTab.linkedBrowser &&
(febeGetBrowser.mCurrentTab.label == "(Untitled)")));
if (currBlank)
{
var resultsWindow = win.loadURI(URL);
} else {
var resultsWindow = win.openNewTabWith(URL, this.docURL, null, null);
}//if
return true;
}//febeOpenLink()
function febeHideHelpIcons(){
var prefName = "extensions.febe.hidehelp";
febeHideHelp = febePrefs.getBoolPref(prefName);
var c = "helpButton";
if(febeHideHelp){c = "none";}
for(var i=1; i<25; i++){
var seq = String(i);
if(i<10){seq = "0".concat(seq);}
var id = "febeHelp".concat(seq);
try{
document.getElementById(id).setAttribute("class",c) ;
}catch(e){;}
}
return true;
}//febeHideHelpIcons()
function febeOptions(aPaneID){
window.openDialog('chrome://febe/content/febeOptions.xul', 'FEBE Options', 'chrome,titlebar,toolbar,centerscreen,resizable');
}//febeOptions()
function febeAlert(message){
window.openDialog("chrome://febe/content/febeAlert.xul", "FEBE Alert", "chrome,modal,dialog=yes,alwaysRaised,centerscreen,resizable",message);
return true;
}//febeAlert()
function febeConfirm(message){
window.openDialog("chrome://febe/content/febeConfirm.xul", "FEBE Confirm", "chrome,modal,dialog=yes,alwaysRaised,centerscreen,resizable",message);
var prefName = "extensions.febe.confirm";
var OK = febePrefs.getBoolPref(prefName);
return OK;
}//febeConfirm()
function febeError(message){
window.openDialog("chrome://febe/content/febeError.xul", "FEBE Error", "chrome,modal,dialog=yes,alwaysRaised,centerscreen,resizable",message);
return true;
}//febeAlert()
function febeConfirmOK(){
var prefName = "extensions.febe.confirm";
febePrefs.setBoolPref(prefName,true);
return true;
}//febeConfirmOK()
function febeConfirmCancel(){
var prefName = "extensions.febe.confirm";
febePrefs.setBoolPref(prefName,false);
return true;
}//febeConfirmOK()
function febeSetAlertMsg(){
febeSetConfirmMsg();
return true;
}//febeSetAlertMsg()
function febeSetConfirmMsg(){
// If the message contains a style, it must be the first part of the message (one style per line, if needed)
var tmp = window.arguments[0]+" \n\n";
var msg = {};
var i = 0;
while(true){ // Break it into an array
var item = new febeAlertObj();
var p = tmp.indexOf("\n");
if(p == -1){break;}
item.Style = "font-family: arial; font-size: 12pt; font-weight: normal; color: purple"; // Default style
var ps1 = tmp.indexOf("<style>");
if(ps1 == 0){
var ps2 = tmp.indexOf("</style>");
if(ps2 != -1){
item.Style = tmp.substr(7,ps2-7); // "7" equals the length of "<style>"
tmp = tmp.replace(tmp.substr(0,ps2+8),""); // Remove the style
p = tmp.indexOf("\n");
}//if
}//if
item.Text = tmp.substr(0,p);
msg[i] = item;
i++;
tmp = tmp.substr(p+1);
}//while
febeClipboard = [];
var msgBox = document.getElementById("febeMsgBox");
for(var i in msg){
var desc = document.createElement("description");
desc.setAttribute("value",msg[i].Text);
desc.setAttribute("style",msg[i].Style);
msgBox.appendChild(desc);
if(febeDebugMode){febeClipboard.push(msg[i].Text);}
}//for
//if(document.getElementById("febeAlertWindow")){
var prefName = "extensions.febe.debugMode";
if(febePrefs.prefHasUserValue(prefName)){
febeDebugMode = febePrefs.getBoolPref(prefName);
} else {
febeDebugMode = false;
}//if
febeDebugMode = febePrefs.getBoolPref(prefName);
document.documentElement.getButton("extra1").hidden = !febeDebugMode;
//}//if
sizeToContent();
var w = window.innerWidth
var padding = w*0.15 // Add some padding it insure all text displays with no scroll bar
window.resizeBy(padding,0);
febePlaySound("alert");
return true;
}//febeSetConfirmMsg()
function febeCopyToClipboard(){
// Copy the contents of a febeAlert, febeConfirm, or febeError box to the system clipboard
var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
gClipboardHelper.copyString(febeClipboard.join("\n"));
return true;
}//febeCopyToClipboard()
function febeAlertObj(Text,Style){
this.Text = Text;
this.Style = Style;
return true;
}//febeAlertObj()
function febePlaySound(which){
var prefName = "extensions.febe.playSounds";
if(febePrefs.prefHasUserValue(prefName)){
febePlaySounds = febePrefs.getBoolPref(prefName);
} else {
febePrefs.setBoolPref(prefName,false);
febePlaySounds = false;
}//if
if(febePlaySounds == false){return;}
var gSound = Components.classes["@mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var soundURL = "chrome://febe/content/sounds/"+which+".wav";
var url = ioService.newURI(soundURL, null, null);
gSound.init();
gSound.play(url);
return true;
}//febePlaySound()
function febeGetTmpDirectory(create_flag){
// Create a tmp directory (create_flag) and/or set a nsI pointer it
var prefName = "extensions.febe.tmpDirectory";
if(!febePrefs.prefHasUserValue(prefName)){febeGetPrefs();}
var tmpdir = febeGetUnicharPref(prefName);
febeTmpDir = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
febeTmpDir.initWithPath(tmpdir);
//febeTmpDir.append("febe.tmp");
if (!(febeTmpDir.exists() && febeTmpDir.isDirectory())){
if(create_flag == true){
febeTmpDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
}//if
}//if
return true;
}//febeGetTmpDirectory()
function febeParent(pathname){
// Return the parent of pathname. Ex:
// If pathname is "C:\Documents and Settings\Owner\My Documents\some dir",
// the function will return "C:\Documents and Settings\Owner\My Documents"
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(pathname);
return file.parent.path;
}//febeParent()
function febeLeafname(pathname){
// Return the leafname of pathname. Ex:
// If pathname is "C:\Documents and Settings\Owner\My Documents\some dir",
// the function will return "some dir"
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(pathname);
return file.leafName;
}//febeLeafname()
function febePause(millis){
// Pause for (millis) milliseconds
var date = new Date();
var curDate = null;
do {curDate = new Date();}
while(curDate-date < millis);
return true;
}//febePause()
function febeUnique(nsiPath,basename){
// Return a unique filname in folder nsiPath with basename of basename
var destDir = nsiPath.clone();
destDir.append(basename);
destDir.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0755);
var unique = destDir.leafName;
return unique;
}//febeUnique()
function febeWrap(str,len){
// Return a string wrapped at len characters max per line
var tmpA = str.split(" ");
var returnVal="";
var tmp = "";
var skip = new Boolean(false);
for(var i = 0; i < tmpA.length; i++){
tmp += tmpA[i]+" ";
if(tmp.length >= len){
returnVal +="\n"+tmpA[i]+" ";
tmp = "";
i--;
skip = true;
}else{
if(skip == false){returnVal += tmpA[i]+" ";}
skip = false;
}//if
}//for
return returnVal;
}//function febeWrap()
function febeFatal(err,msg){
//alert("febeIgnoreError: "+febeIgnoreError)
if(febeIgnoreError == true){
febeIgnoreError = false; // Reset
return true;
}//if
// Display fatal errors
var style = "<style>color: black;font-size: 8pt;</style>";
var tmp = febeWrap(err.toString(),100);
tmp = tmp.replace(/\n/g,"\n"+style);
tmp = style + tmp;
tmp +="\n\n";
var ptSize = 12;
if(msg.length > 100){ptSize = 8;}
style = "<style>color: red;font-size: "+ptSize+"pt;</style>";
msg = msg.replace(/\n/g,"\n"+style);
tmp += style+msg;
febeError(tmp);
return true;
}//febeFatal()
function febeDisplayLastBU(){
var prefName = "extensions.febe.lastbackup";
if(febePrefs.prefHasUserValue(prefName)){
var tmp = febePrefs.getCharPref(prefName);
tmp = febeLocalizedDate(tmp);
} else {
var tmp = febeMsg[173];
}//if
document.getElementById("febeLastBU").value = tmp;
return true;
}//febeDisplayLastBU()
function febeLocalizedDate(aDate){
var lDate = new Date(aDate)
return lDate.toLocaleDateString()+" "+lDate.toLocaleTimeString();
}//febeLocalizedDate()
function febeMakeExecutable(fileName){
// Set execute permission on fileName
if(febePlatform == 1){return true;} // Ignore Windows platform
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("/");
file.append("bin");
file.append("chmod");
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
var argv = ["0755",fileName];
process.run(true, argv, argv.length);
return true;
}//febeMakeExecutable()
//alert("febeCommon.js loaded");